{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-21T05:16:10.327160Z",
     "start_time": "2025-09-21T05:15:56.969630Z"
    }
   },
   "source": [
    "from selenium import webdriver\n",
    "\n",
    "options = webdriver.ChromeOptions()\n",
    "options.add_experimental_option(\n",
    "    'excludeSwitches', ['enable-logging']\n",
    ")\n",
    "\n",
    "# 创建 WebDriver 对象\n",
    "wd = webdriver.Chrome()\n",
    "\n",
    "# 调用WebDriver 对象的get方法 可以让浏览器打开指定网址\n",
    "wd.get('https://www.byhy.net')\n",
    "\n",
    "# 程序运行完会自动关闭浏览器，就是很多人说的闪退\n",
    "# 这里加入等待用户输入，防止闪退\n",
    "input('按回车退出')\n",
    "\n",
    "# 关闭浏览器窗口\n",
    "wd.quit()"
   ],
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Exception managing chrome: error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json)\n"
     ]
    }
   ],
   "execution_count": 9
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "75b1b99d9d227954"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
